package com.kuaiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kuaiyin.entity.TestPlanCase;
import com.kuaiyin.enums.Status;
import org.apache.ibatis.annotations.Param;
import com.kuaiyin.vo.TestPlanCaseVO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 测试计划-用例关联表 Mapper 接口
 * </p>
 *
 * @author ng
 * @since 2025-04-30
 */
public interface TestPlanCaseMapper extends BaseMapper<TestPlanCase> {

    void deleteByPlanId(Long id);

    List<TestPlanCaseVO> selectAllCasesByPlanIds(@Param("list") List<Long> planIds);

    @Update("update test_plan_case set status = #{status} where plan_id = #{id}")
    void updateStatusByPlanId(Long id, Status status);
    
    @Select("select response_extract from test_plan_case where plan_id = #{id} and case_id = #{caseId}")
    Map<String, String> getResponseExtract(Long id, Long caseId);
    
    @Select("select plan_id from test_plan_case where case_id = #{id}")
    List<Long> selectCasesByPlanIds(Long id);

    @Select("select case_id from test_plan_case where plan_id = #{id} order by execution_order")
    List<Long> selectPlanByCaseIds(Long id);

    void updatajmxResponseExtract(Long planId, String caseId, Map<Object, Object> valueMap);
}
